#include "ThreadMgr.h"
#include <process.h>
#include <Windows.h>


unsigned __stdcall ThreadMgr::thread_func(void* param)
{
	Sleep(5);

	ThreadTask* task = (ThreadTask*)param;
	while (!task->DoTask())
	{
		task->Wait();
	}

	delete task;

	_endthreadex(0);

	return 0;
}

void ThreadMgr::AddTask( ThreadTask* task )
{
	unsigned int dwThreadId;
	_beginthreadex(NULL, 0, &thread_func, task, 0, &dwThreadId);
}